package com.kucai.yifaqapp.presenter.activity;

import com.kucai.yifaqapp.global.HttpAdress;
import com.kucai.yifaqapp.model.CustomObserver;
import com.kucai.yifaqapp.model.network.HttpJsonUtils;
import com.kucai.yifaqapp.model.network.entity.res.ResBanner;
import com.kucai.yifaqapp.model.network.entity.res.ResLottery;
import com.kucai.yifaqapp.ui.activity.LotteryopenActivity;
import com.kucai.yifaqapp.util.SYSOUtils;

import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable;
import io.reactivex.schedulers.Schedulers;

/**
 * Created by Administrator on 2018/11/30.
 */

public class LotteryopenActivityPresenter extends BaseActivityPresenter<LotteryopenActivity> {
    public LotteryopenActivityPresenter(LotteryopenActivity mActivity) {
        super(mActivity);
    }

    //获取游戏列表
    public void getbanner() {
        HttpJsonUtils.getHttpApiInstance()
                .getbanner(HttpAdress.getuseAdress() + "api/m/lottery/getHomeLotteryData")
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new CustomObserver<ResBanner>() {

                    @Override
                    protected void onCustomNext(ResBanner resBanner) {
                        SYSOUtils.sOut_("全部彩种" + resBanner);
                        mActivity.getgamelist(resBanner);
                    }

                    @Override
                    protected void onSubscribeCustom(Disposable disposable) {
                    }

                    @Override
                    protected void onErrorCustom(Throwable e) {

                    }
                });
    }

    public void getlottery(String data, String id, int rows) {
        HttpJsonUtils.getHttpApiInstance()
                .getlottery(HttpAdress.getuseAdress() + "api/m/lotteryHistory/data",data, id, rows, "15")
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new CustomObserver<ResLottery>(mActivity) {

                    @Override
                    protected void onCustomNext(ResLottery resLottery) {
                        if ("0".equals(resLottery.code) && resLottery.data != null) {
                            mActivity.getlottery(resLottery);
                        }
                    }

                    @Override
                    protected void onSubscribeCustom(Disposable disposable) {
                    }

                    @Override
                    protected void onErrorCustom(Throwable e) {

                    }
                });
    }
}